﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace sconSDK
{
    public class DebugInfo
    {
        private int m_position;

        public int Position
        {
            get { return m_position; }
            set { m_position = value; }
        }
        private int m_line;

        public int Line
        {
            get { return m_line; }
            set { m_line = value; }
        }
        private int m_loop;

        public int Loop
        {
            get { return m_loop; }
            set { m_loop = value; }
        }
        private int m_stack;

        public int Stack
        {
            get { return m_stack; }
            set { m_stack = value; }
        }

        public override string ToString()
        {
            return "Pos: " + m_position + " Line: " + m_line + " Loop: " + m_loop + " Stack: " + m_stack;
        }

        public DebugInfo(string portData)
        {
            if (portData.Length == 24 &&
                portData.Substring(0, 2).CompareTo("AB") == 0)
            {
                m_position = Convert.ToInt32(portData.Substring(2, 4), 16);
                m_stack = Convert.ToInt32(portData.Substring(6, 4), 16);
                m_loop = Convert.ToInt32(portData.Substring(10, 4), 16);
                m_line = Convert.ToInt32(portData.Substring(20, 4), 16) - 1;
            }
        }
    }
}
